<?php
class Merchant_Service_ProductStocketLog
{
	public function __construct(){
		
	}

	public static function getByProductId($id){		
		$obj = new Merchant_Model_ProductStocketLog();
		return $obj->getByProductId($id);		
	}
	public static function getByProductIdCustomerId($productId,$customerId=null){
		$wps = self::getByCondition(array("product_id"=> $productId));
		if(is_array($wps) && !empty($wps)){
			$productService = new Merchant_Service_Product();
			foreach($wps as $key=>$value){
				$product = $productService->getProductInfo($value['product_id'],$customerId);
				if(is_array($product) && !empty($product)){
					$wps[$key]['product'] = $product;
				}else{
					unset($wps[$key]);
				}
			}
				
			return empty($wps)?false:$wps;
		}
		return false;
	}
	
	

	public static function getByCondition($condition=array(),$type='*',$order=array('product_id'), $pageSize=0, $page=1)
	{ 
		$obj=new Merchant_Model_ProductStocketLog();
		$rows= $obj->getByCondition( $condition,$type,$order, $pageSize,$page);	
		return $rows;
	}
	
	public static function getByConditionJoin($condition=array(),$type='*',$order=array('psl_add_time desc '), $pageSize=0, $page=1)
	{
		$obj=new Merchant_Model_ProductStocketLog();
		$rows= $obj->getByConditionJoin( $condition,$type,$order, $pageSize,$page);
		return $rows;
	}
	
	public  static function getProductStocketLogByProductId($productId,$page,$pageSize){
		
		$obj = new Merchant_Model_ProductStocketLog();
		$rows= $obj->getProductStocketLogByProductId($productId,$page,$pageSize);
		return $rows;
	}
	
	public function getAdapter(){
		$model = new Merchant_Model_ProductStocketLog();
		return $model->getAdapter();
	}
	
	public function update($row,$id){
		$model = new Merchant_Model_ProductStocketLog();
		return $model->update($row,$id);
	}
	
	public static function create($row)
	{ 
		$obj=new Merchant_Model_ProductStocketLog();
		return $obj->add($row);
	}
	
	
}